package br.trainee.web.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.enterprise.inject.Produces;
import br.trainee.web.anotacoes.ConnectionQualifier;
import br.trainee.web.enumeradores.TipoConexao;

public class ConnectionFactory {
	
	
	@Produces
	@ConnectionQualifier(tipoConexao = TipoConexao.ORACLE)
	public Connection getConexaoOracle(){
		
		Connection conexao = null;
		
		try {
	
			Class.forName("oracle.jdbc.driver.OracleDriver");
			conexao = DriverManager.getConnection("jdbc:oracle:thin:@192.168.2.27:1521:xe","fernando","maker123");
			
			
		} catch (ClassNotFoundException e) {
		
			e.printStackTrace();
		} catch (SQLException e) {
			
			e.printStackTrace();
		}
		
		
		return conexao;
		
	}
	
	@Produces
	@ConnectionQualifier(tipoConexao = TipoConexao.SQL_SERVER)
	public Connection getConexaoSqlServer(){
		
		Connection conexao = null;
		/*
		try {
	
			Class.forName("net.sourceforge.driver.Driver");
			conexao = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/nomebanco","sa","sql");
			
			
		} catch (ClassNotFoundException e) {
			
			e.printStackTrace();
		} catch (SQLException e) {

			e.printStackTrace();
		}
		*/
		System.out.println("Instância do slq Server");
		return conexao;
	}

}
